1422A - Fence - CodeForces Solution


geometry math *800

Please click on ads to support us..

Python Code:

import math as m
t = int(input())
for _ in range(t):
    a,b,c = list(map(int,input().split()))
    Min = min(a,b,c)
    Max = max(a,b,c)
    x = Max-Min
    d = m.ceil(m.sqrt(Min**2+x**2))
    print(d)

C++ Code:

                //~~~  Shree Ganeshaay Naamh ~~~//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
const double eps = 1e-6;
const ll M=1e9+7;
#define pb emplace_back
#define pbs push_back
#define ff first
#define ss second
#define mpp make_pair
#define srt(x) sort(x.begin(), x.end())
#define srtg(x) sort(x.begin(), x.end(),greater<>())
#define all(v) v.begin(),v.end()
#define pree(x) cout << fixed << setprecision(10) << x
#define l_b lower_bound
#define u_b upper_bound


// Sieve code
/*
const ll N= 1000000;
bool sieve[N+1];

void createsieve(){
    sieve[0] = sieve[1] = true;
    sieve[2]=false;
    for(ll i=2;i*i<N;i++){
          if(sieve[i]==false){
        for(ll j=i*i;j<N;j=j+i){
            sieve[j] = true;
        }
      }
    } 
    
}
*/

bool ispal(string s){
    
 ll n = s.length();

 for(ll i=0;i<n/2;i++){
     if(s[i]!=s[n-i-1]){
         return false;
     }
 }
   return true;
}

ll andOperator(ll n, ll m){

  ll answer = 0;

  for(ll i = 63 ;i>=0; i--){
      if((m&(1ll<<i))!=(n&(1ll<<i))){
         break;
      }else{
         answer |= (n&(1ll<<i));
      }
  }
  return answer;
}

ll power(ll a,ll b,ll p){
    ll res=1;
    if(a==0){
        return 0;
    }
    while(b>0){
        if(b%2!=0){
            res=(res*a)%p;
        }
        b=b/2;
        a=(a*a)%p;
    }
    return res;
}

int main(){
  
    
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
  ll t;
  cin>>t;
  while(t--){
  
  ll a,b,c;
  cin>>a>>b>>c;
  ll d =max(a,max(b,c));
  if(d==1){
    cout<<1<<"\n";
  }else{
  cout<<d-(ll)1<<"\n";
  }

  }

  return 0;
}


Comments

Submit
0 Comments
More Questions

911A - Nearest Minimums
102B - Sum of Digits
707A - Brain's Photos
1331B - Limericks
305B - Continued Fractions
1165B - Polycarp Training
1646C - Factorials and Powers of Two
596A - Wilbur and Swimming Pool
1462B - Last Year's Substring
1608B - Build the Permutation
1505A - Is it rated - 2
169A - Chores
765A - Neverending competitions
1303A - Erasing Zeroes
1005B - Delete from the Left
94A - Restoring Password
1529B - Sifid and Strange Subsequences
1455C - Ping-pong
1644C - Increase Subarray Sums
1433A - Boring Apartments
1428B - Belted Rooms
519B - A and B and Compilation Errors
1152B - Neko Performs Cat Furrier Transform
1411A - In-game Chat
119A - Epic Game
703A - Mishka and Game
1504C - Balance the Bits
988A - Diverse Team
1312B - Bogosort
1616B - Mirror in the String